import java.util.Scanner;
import java.util.ArrayList;

public class SchoolSystem {
    int IntegerBig;
    int IntergerMedium;
    int IntergerSmall;

    ArrayList<Student>array =new ArrayList<Student>();
    Scanner in =new Scanner(System.in);

    public void SchoolSystem1(int IntegerBig,int IntegerMedium,int IntegerSmall) {
        this.IntegerBig = IntegerBig;
        this.IntergerMedium =IntegerMedium;
        this.IntergerSmall = IntegerSmall;

    }
    public boolean addStudent(ArrayList<Student>array){//检查是否有stuType对应的班级
        for(int i=0;;i++){
            System.out.println("请输入您要查询的班级(1：大班，2：中班，3：小班，0：退出)");
            int stuType=in.nextInt();
            if(stuType==1){
                if(IntegerBig!=0){
                    System.out.println("剩余"+IntegerBig+"个名额");
                    System.out.println("录入学生信息");
                    System.out.println("请输入学生姓名：");
                    String name=in.next();
                    System.out.println("请输入学生班级：");
                    String schoolsystem1=in.next();
                    Student s=new Student();
                    s.setName(name);
                    s.setSchoolsystem1(schoolsystem1);
                    array.add(s);
                    IntegerBig--;
                    return true;//有剩余的班级名额，返回true
                }
                else{
                    System.out.println("无剩余名额");
                    return false;//没有剩余多的班级人数，返回false
                }
            }
            else if(stuType==2){
                if(IntergerMedium!=0){
                    System.out.println("剩余"+IntergerMedium+"个名额");
                    System.out.println("录入学生信息");
                    System.out.println("请输入学生姓名：");
                    String name=in.next();
                    System.out.println("请输入学生班级：");
                    String schoolsystem1=in.next();
                    Student s=new Student();
                    s.setName(name);
                    s.setSchoolsystem1(schoolsystem1);
                    array.add(s);
                    IntergerMedium--;
                    return true;//有剩余的班级名额，返回true
                }
                else {
                    System.out.println("无剩余名额");
                    return false;//没有剩余多的班级人数，返回false
                }
            }
            else if(stuType==3) {
                if (IntergerSmall != 0) {
                    System.out.println("剩余" + IntergerSmall + "个名额");
                    System.out.println("录入学生信息");
                    System.out.println("请输入学生姓名：");
                    String name = in.next();
                    System.out.println("请输入学生班级：");
                    String schoolsystem1 = in.next();
                    Student s = new Student();
                    s.setName(name);
                    s.setSchoolsystem1(schoolsystem1);
                    array.add(s);
                    IntergerSmall--;
                    return true;//有剩余的班级名额，返回true
                } else {
                    System.out.println("无剩余名额");
                    return false;//没有剩余多的班级人数，返回false
                }
            }
            else if(stuType==0){
                System.out.println("退出成功");
                return false;
            }
        }
    }
    public void print(ArrayList<Student>array){//输出结果
        for(int i=0;i<array.size();i++){
            Student s=array.get(i);
            System.out.println(s.getName()+","+s.getSchoolsystem1());
        }
    }
}
class Student{
    String name;
    String schoolsystem1;
    public void student(String name,String schoolsystem1){
        this.name=name;
        this.schoolsystem1=schoolsystem1;
    }
    public String getName(){//获取姓名
        return name;
    }
    public String getSchoolsystem1(){//获取班级
        return schoolsystem1;
    }
    public void setName(String name){
        this.name=name;
    }
    public void setSchoolsystem1(String schoolsystem1){
        this.schoolsystem1=schoolsystem1;
    }
}

class  Demo{
    public static void main(String[] args) throws Exception{

        ArrayList<Student> array = new ArrayList<Student>();
        Scanner in = new Scanner(System.in);
        SchoolSystem a = new SchoolSystem();
        a.SchoolSystem1(1, 2, 3);//初始化大班有1个名额，中班有2个名额，小班有3个名额
        while (a.addStudent(array)) {
            a.addStudent(array);
        }
        System.out.println("班级学生信息");
        a.print(array);
    }
}












